package com.nmgs.controller;

import com.nmgs.common.Result;
import com.nmgs.dto.ScreenDto;
import com.nmgs.dto.SpecialEventDto;
import com.nmgs.service.ISpecialEventService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/specialEvent")
public class SpecialController {

    public ISpecialEventService specialEventService;
    @Autowired
    public void setSpecialEventService(ISpecialEventService specialEventService) {
        this.specialEventService = specialEventService;
    }
    @PostMapping("getSpecialList")
    @ResponseBody
    public Result<List<SpecialEventDto>> getSpecialList(HttpServletRequest request, @RequestBody Map<String, Object> req){
        List<SpecialEventDto> specialList = specialEventService.getSpecialList(req);
        return Result.success(specialList,specialList.size());
    }
    @PostMapping("getSpecialSolveList")
    @ResponseBody
    public Result<List<SpecialEventDto>> getSpecialSolveList(HttpServletRequest request, @RequestBody Map<String, Object> req){
        List<SpecialEventDto> specialList = specialEventService.getSpecialSolveList(req);
        return Result.success(specialList,specialList.size());
    }
    @PostMapping("getLaneData")
    @ResponseBody
    public Result<SpecialEventDto> getLaneData(HttpServletRequest request, @RequestBody Map<String, Object> req){
        SpecialEventDto specialList = specialEventService.getLaneData(req);
        return Result.success(specialList,1);
    }
    @PostMapping("getSpecialListStat")
    @ResponseBody
    public Result<SpecialEventDto> getSpecialListStat(HttpServletRequest request, @RequestBody Map<String, Object> req){
        List<SpecialEventDto> specialList = specialEventService.getSpecialListStat(req);
        return Result.success(specialList.get(0),specialList.size());
    }
    @PostMapping("getSpecialReason")
    @ResponseBody
    public Result<List<SpecialEventDto>> getSpecialReason(HttpServletRequest request, @RequestBody Map<String, Object> req){
        List<SpecialEventDto> specialList = specialEventService.getSpecialReason(req);
        return Result.success(specialList,specialList.size());
    }
    @PostMapping("getSpecialSolveStat")
    @ResponseBody
    public Result<SpecialEventDto> getSpecialSolveStat(HttpServletRequest request, @RequestBody Map<String, Object> req){
        List<SpecialEventDto> specialList = specialEventService.getSpecialSolveStat(req);
        return Result.success(specialList.get(0),specialList.size());
    }
    @PostMapping("getSpecialRank")
    @ResponseBody
    public Result<List<SpecialEventDto>> getSpecialRank(HttpServletRequest request, @RequestBody Map<String, Object> req){
        List<SpecialEventDto> specialList = specialEventService.getSpecialRank(req);
        return Result.success(specialList,specialList.size());
    }

}
